import {defineConfig} from './src/internal/vite-config';

import ElementPlus from 'unplugin-element-plus/vite';
import path from "path";
import tsconfigPaths from 'vite-tsconfig-paths'

export default defineConfig(async () => {
    return {
        application: {},
        vite: {
            plugins: [
                ElementPlus({
                    format: 'esm',
                }),
                tsconfigPaths()
            ],
            resolve: {
                alias: {
                    // 设置路径
                    '~': path.resolve(__dirname, './'),
                    // 设置别名
                    '@': path.resolve(__dirname, './src'),
                    // 添加#/locales路径别名
                    '#': path.resolve(__dirname, './src'),
                    // 添加与tsconfig.json相同的路径别名
                    '@vben-core/design': path.resolve(__dirname, './src/packages/@core/base/design'),
                    '@vben-core/icons': path.resolve(__dirname, './src/packages/@core/base/icons'),
                    '@vben-core/shared': path.resolve(__dirname, './src/packages/@core/base/shared'),
                    '@vben-core/typings': path.resolve(__dirname, './src/packages/@core/base/typings'),
                    '@vben-core/composables': path.resolve(__dirname, './src/packages/@core/composables'),
                    '@vben-core/preferences': path.resolve(__dirname, './src/packages/@core/preferences'),
                    '@vben-core/form-ui': path.resolve(__dirname, './src/packages/@core/ui-kit/form-ui'),
                    '@vben-core/layout-ui': path.resolve(__dirname, './src/packages/@core/ui-kit/layout-ui'),
                    '@vben-core/menu-ui': path.resolve(__dirname, './src/packages/@core/ui-kit/menu-ui'),
                    '@vben-core/popup-ui': path.resolve(__dirname, './src/packages/@core/ui-kit/popup-ui'),
                    '@vben-core/shadcn-ui': path.resolve(__dirname, './src/packages/@core/ui-kit/shadcn-ui'),
                    '@vben-core/tabs-ui': path.resolve(__dirname, './src/packages/@core/ui-kit/tabs-ui'),
                    '@vben/constants': path.resolve(__dirname, './src/packages/constants'),
                    '@vben/access': path.resolve(__dirname, './src/packages/effects/access'),
                    '@vben/common-ui': path.resolve(__dirname, './src/packages/effects/common-ui'),
                    '@vben/hooks': path.resolve(__dirname, './src/packages/effects/hooks'),
                    '@vben/layouts': path.resolve(__dirname, './src/packages/effects/layouts'),
                    '@vben/plugins': path.resolve(__dirname, './src/packages/effects/plugins'),
                    '@vben/plugins/echarts': path.resolve(__dirname, './src/packages/effects/plugins/echarts'),
                    '@vben/plugins/motion': path.resolve(__dirname, './src/packages/effects/plugins/motion'),
                    '@vben/plugins/vxe-table': path.resolve(__dirname, './src/packages/effects/plugins/vxe-table'),
                    '@vben/request': path.resolve(__dirname, './src/packages/effects/request'),
                    '@vben/icons': path.resolve(__dirname, './src/packages/icons'),
                    '@vben/locales': path.resolve(__dirname, './src/packages/locales'),
                    '@vben/preferences': path.resolve(__dirname, './src/packages/preferences'),
                    '@vben/stores': path.resolve(__dirname, './src/packages/stores'),
                    '@vben/styles': path.resolve(__dirname, './src/packages/styles'),
                    '@vben/types': path.resolve(__dirname, './src/packages/types'),
                    '@vben/utils': path.resolve(__dirname, './src/packages/utils')
                },
                extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
            },
            server: {
                proxy: {
                    '/api': {
                        changeOrigin: true,
                        rewrite: (path) => path.replace(/^\/api/, ''),
                        // mock代理目标地址
                        target: 'https://mock-napi.vben.pro/api',
                        ws: true,
                    },
                },
            },
        },
    };
}, 'application');
